import React, {
	Component,
	PropTypes
} from 'react'
import Item from './item.js'
import fetchWeiboHotData from './action.js'

class weiboHotLists extends Component {
	componentDidMount() {
		const {
			dispatch
		} = this.props
		dispatch(fetchWeiboHotData())
	}
	handleClick() {
		const {
			dispatch
		} = this.props
		dispatch(fetchWeiboHotData())
	}
	render() {
		return (
			<div>
				{
					Array.prototype.map.call(this.props.lists,(elem, index) => {
						return <Item item={elem} key={index}/>
					})
				}	
				<button onClick={this.handleClick.bind(this)}>Refresh</button>
			</div>
		)
	}
}

weiboHotLists.defaultProps = {
	lists: [{
		title: "Loading......"
	}]
}

export default weiboHotLists